/*
模块功能：使用sw0 sw1的拨码开关进行状态的切换
         在不同的状态下，led灯以不同的样式点亮
sw0  0 0 1 1 
sw1  0 1 0 1
----------------
led0 1 0 0 0
led1 0 1 0 0
led2 0 0 1 0
led3 0 0 0 1
*/

module led(
    input  wire  clk,//125M
    //input  wire  rst_async_n,
    input  wire  rst_async_n,
    input  wire  sw1,
    output reg   led0,
    output reg   led1,
    output reg   led2,
    output reg   led3  
);
//组合逻辑
//assign led0=1;
rst_sync rst_sync_inst(
  .clk_i        (clk),
  .rst_async_n_i(rst_async_n),
  .rst_sync_n_o (rst_sync_n)
);


always @(posedge clk)begin
    if(!rst_sync_n)begin//手指松开之后，
        led0<=0;
        led1<=0;
        led2<=0;
        led3<=0;
    end 
    else if(sw1==1)begin
        led0<=1;
        led1<=1;
        led2<=0;
        led3<=0;
    end    
    else if(sw1==0)begin
        led0<=0;
        led1<=0;
        led2<=1;
        led3<=1;
    end    
    else begin
        led0<=led0;
        led1<=led1;
        led2<=led2;
        led3<=led3;
    end
end
/*
always @(sw0 or sw1) begin
    if(sw0==0 && sw1==0)begin
        led0=1;
        led1=0;
        led2=0;
        led3=0;
    end    
    else if(sw0==0 && sw1==1)begin
        led0=0;
        led1=1;
        led2=0;
        led3=0;
    end
    else if(sw0==1 && sw1==0)begin
        led0=0;
        led1=0;
        led2=1;
        led3=0;
    end
    else if(sw0==1 && sw1==1)begin
        led0=0;
        led1=0;
        led2=0;
        led3=1;
    end
    else begin
        led0=1;
        led1=1;
        led2=1;
        led3=1;
    end
end
*/



//异步复位
/*
always @(posedge clk or negedge rst)begin
    if(!rst)begin//手指松开之后，
        led0=0;
        led1=0;
        led2=0;
        led3=0;
    end
end
*/
//assign led0=0;





endmodule




//(led0==1 || led1==1)逻辑或
//(led0 | led1)位或
